﻿using System.Collections.Generic;
using OS.Common.Enums;

namespace OS.Common.Core
{
    /// <summary>
    /// 自定义搜索实体
    /// </summary>
    public class CustomSearch
    {
        private int _currentPage = 1;

        private int _pageSize = 20;

        /// <summary>
        /// 当前页
        /// </summary>
        public int CurrentPage
        {
            get => _currentPage > 0 ? _currentPage : 1;
            set => _currentPage = value;
        }

        /// <summary>
        /// 页面大小
        /// </summary>
        public int PageSize
        {
            get => _pageSize > 0 ? _pageSize : 20;
            set => _pageSize = value;
        }

        /// <summary>
        /// 起始行 -》只读属性
        /// </summary>
        public int StartRow => (CurrentPage - 1) * PageSize;

        /// <summary>
        /// 排序集合，适用于多个查询条件
        /// </summary>
        public Dictionary<string, SortType> OrderDictionaries { get; set; }

        /// <summary>
        /// 搜索关键字集合，适用于多个查询条件
        /// </summary>
        public Dictionary<string, string> FilterDictionaries { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CustomSearch()
        {
            FilterDictionaries = new Dictionary<string, string>();
            OrderDictionaries = new Dictionary<string, SortType>();
        }
    }
}